<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>QUnit for CSR ASN1 Encoder Class 'asn1csr.js'</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />


<script src="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>


<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/rsa.js"></script>
<script src="../ext/rsa2.js"></script>
<script src="../ext/base64.js"></script>
<script src="../src/base64x-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/rsapem-1.1.js"></script>
<script src="../src/crypto-1.1.js"></script>
<script src="../src/asn1-1.0.js"></script>
<script src="../src/asn1x509-1.0.js"></script>
<script src="../src/keyutil-1.0.js"></script>
<script src="../src/rsasign-1.2.js"></script>
<script src="../src/asn1csr-1.0.js"></script>
<script src="../src/x509-1.1.js"></script>

<script language="JavaScript" type="text/javascript" src="../ext/ec.js"></script>
<script language="JavaScript" type="text/javascript" src="../ext/ec-patch.js"></script>
<script language="JavaScript" type="text/javascript" src="../src/ecdsa-modified-1.0.js"></script>
<script language="JavaScript" type="text/javascript" src="../src/ecparam-1.0.js"></script>
<script language="JavaScript" type="text/javascript" src="../src/dsa-2.0.js"></script>

<script type="text/javascript">
<!--
$(document).ready(function(){

// _test/z1.*
var z1PubP8PEM = "" +
"-----BEGIN PUBLIC KEY-----\n" +
"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOhmTdK0BSkSFWjzs5vJemLnujwJur3E\n" +
"8NzY35DreQubtkWitw4xEnR7TTxBtRQkiVEV/viPedQ+rlsaTjUY/VkCAwEAAQ==\n" +
"-----END PUBLIC KEY-----\n";

var z1PrvP5EPEM = "" +
"-----BEGIN RSA PRIVATE KEY-----\n" +
"Proc-Type: 4,ENCRYPTED\n" +
"DEK-Info: DES-EDE3-CBC,4626F2E5853E783F\n" +
"\n" +
"3vFpkrnbantC8RSzng2+jBw/VX95oi0VGKP0G8whENHUOVQXB/YOUSj+n80Y0Wwc\n" +
"GpeQi8U0FQdWyYv8b9aioeFB06r9t9mJsYscJ/wcIvv5tTMkr89cwN3+4GQQuqNg\n" +
"TmI9ekeoZ3NP26hTM4XTuFqHx4dzNNwjDLc8txc77WE/o4J4p8k9Py5yPZjs9EKy\n" +
"wy/yxtqQYQuFj90OMEG1G89iHTZRcq4YTZYdqg6P/XEUvyjifN+7Nym8f2N9TDDn\n" +
"RJtApPQlrgXvUDQKz6Lu1ZYMwe94E9YdutDGQMbxixbiyxlcxrkb/oEHH5WP5qPG\n" +
"w/xzh08Ce2Ftba2Q860S8nznjyZFiv+lqSKBahbujgP/63ZL+JbAd4cYBqgm4g1C\n" +
"YwMhHJbaVCzwYduxdyK2JBYEosDZiDfnOP4DqPhJYpg=\n" +
"-----END RSA PRIVATE KEY-----\n";
var z1PrvP5EPass = "hoge";

var z1CertPEM = "" +
"-----BEGIN CERTIFICATE-----\r\n" +
"MIIBfzCCASmgAwIBAgIBBDANBgkqhkiG9w0BAQUFADAZMQswCQYDVQQGEwJVUzEK\r\n" +
"MAgGA1UECgwBYTAeFw0xMzA1MDQyMzU5NTlaFw0xNDA1MDQyMzU5NTlaMBkxCzAJ\r\n" +
"BgNVBAYTAlVTMQowCAYDVQQKDAFiMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAOhm\r\n" +
"TdK0BSkSFWjzs5vJemLnujwJur3E8NzY35DreQubtkWitw4xEnR7TTxBtRQkiVEV\r\n" +
"/viPedQ+rlsaTjUY/VkCAwEAAaNcMFowDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8E\r\n" +
"BAMCBsAwJQYDVR0fBB4wHDAaoBigFoYUaHR0cDovL2FhYS5jb20vYS5jcmwwEwYD\r\n" +
"VR0lBAwwCgYIKwYBBQUHAwIwDQYJKoZIhvcNAQEFBQADQQAMUx/hyfWr2779id/7\r\n" +
"p6lHAFZTN+HBwfoq6c1reeVtk7JKD+18dYbKJcwbLLj2CEv04fm+MQ5p8mY7r5Aa\r\n" +
"558s\r\n" +
"-----END CERTIFICATE-----\r\n";

// _gitpg/jsrsasign/test/eckey/k1.*
var k1PubP8PEM = "" +
"-----BEGIN PUBLIC KEY-----\n" +
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoBUyo8CQAFPeYPvv78ylh5MwFZjT\n" +
"CLQeb042TjiMJxG+9DLFmRSMlBQ9T/RsLLc+PmpB1+7yPAR+oR5gZn3kJQ==\n" +
"-----END PUBLIC KEY-----\n";

var k1PrvP8PPEM = "" +
"-----BEGIN PRIVATE KEY-----\n" +
"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgEbVzfPnZPxfAyxqE\n" +
"ZV05laAoJAl+/6Xt2O4mOB611sOhRANCAASgFTKjwJAAU95g++/vzKWHkzAVmNMI\n" +
"tB5vTjZOOIwnEb70MsWZFIyUFD1P9Gwstz4+akHX7vI8BH6hHmBmfeQl\n" +
"-----END PRIVATE KEY-----\n";

// _work_dsa/d1.pub.p8.pem
var d1PubP8PEM = "" +
"-----BEGIN PUBLIC KEY-----\n" +
"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n" +
"kslgs45yRNUznxxMi/61sm6pkH///ow0w5DN74UQsqpJj4CYhhNQY4r/QnK8SvlL\n" +
"+KFXazkFwWNZbXiyxF7zdaCsb5bglvfmJspSDGUIcxPzwMG1GQBA3IqOegjmgU/5\n" +
"LMElak/HMFFjT+jUUvxVSJIWK7f4+lWypwPkmmZib9dx8XHPpUr/vXBwPLE40fRG\n" +
"9enP7lSZRWjmW9alWIn6dpjG5HsQwH4eMxdD1fqLR7BR+nx+z47wqmAXPIzOL7PW\n" +
"N4nVxc1+juzITbT6HZB5gkHJG/5l/YFDsACK8aLHp+lgM/Onyg3cMDKSbaXERPZb\n" +
"q0MrwzdrLyCc6x9HYz2QDA==\n" +
"-----END DSA PRIVATE KEY-----\n";
var d1PrvP5EPass = "passwd";

// _data/0csr1/key2.pub
var key2pub = (function() {/*
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5/2QHMBBvirriuchipR5
02Ra3oN/jduXlIFi0eWpQem2S0IrKwgiBX9+hNnjhqMhOXp4k/6IuCOH6PIRpJSk
F1N/tu7ypzTVwnT8LQof5daRQteHFPU3w3MelduE5nGPjJl8jcV36jtvt7nnkZjJ
vZPluQLNAt6azIvI31BQqNID1x3RIDTxVa6A952undto669sUuOcjUCFxwYCk3u5
m89RpayoyAEK3rq6XbSF+spirWLHeDF0d58hMGvbwI8YPnp7dNRPU08Wg9QUJE8l
JEfMyAXOYa2eKRk9mqB7jkEYDHiqNPzjsm3CT0amn8e2B+dQUYgSe3Rnj58ToiIr
xQIDAQAB
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

// _data/0csr1/key2.prv
var key2prv = (function() {/*-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA5/2QHMBBvirriuchipR502Ra3oN/jduXlIFi0eWpQem2S0Ir
KwgiBX9+hNnjhqMhOXp4k/6IuCOH6PIRpJSkF1N/tu7ypzTVwnT8LQof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Lu1EpsYTZy6imH/jtQcLUz589VX5Az98GRZE
3IwbamFNVjB2BN1IEIzW2vt3AoGAMrpgnO3bnKa9YTmp35yLCBma/Zt0pqeTdIqa
ic4nhZ+jLQ3JKpeWXgtsMfQhxeHWYrgkaRKwxnLy1W9BIwQU9o78UcYcrJfzJoJ1
SIb6OzaBaOQcmQlOjhUsBrt8/fQX/H7N1U7h0ayXwj0e4/6r8wwPueLPWyFw9lbU
ofOx5CcCgYEAvTTcxuj6jscA33tFPa+SWM2QT8JFMxftjVTitUBdPntRWCawwzqY
yIaCKBkF8f03cTS3yz1ZiE3M1OQs1zuaUxJVTr1VpSUV+pxTuZ3gq3i/9QHadVrE
MGpevmzMV1eLDgIjvOUFkBskHqfKieaNYsP33jnqlv6Zi8Z6NVYPVDc=
-----END RSA PRIVATE KEY-----*/}).toString().match(/\/\*([^]*)\*\//)[1];

// _data/0csr1/key2.csr.hex (generated by OpenSSL SHA256)
var key2csrhex = "308202773082015f0201003032310b3009060355040613025553310d300b060355040a0c04546573743114301206035504030c0b6578616d706c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100e7fd901cc041be2aeb8ae7218a9479d3645ade837f8ddb97948162d1e5a941e9b64b422b2b0822057f7e84d9e386a321397a7893fe88b82387e8f211a494a417537fb6eef2a734d5c274fc2d0a1fe5d69142d78714f537c3731e95db84e6718f8c997c8dc577ea3b6fb7b9e79198c9bd93e5b902cd02de9acc8bc8df5050a8d203d71dd12034f155ae80f79dae9ddb68ebaf6c52e39c8d4085c70602937bb99bcf51a5aca8c8010adebaba5db485faca62ad62c7783174779f21306bdbc08f183e7a7b74d44f534f1683d414244f252447ccc805ce61ad9e29193d9aa07b8e41180c78aa34fce3b26dc24f46a69fc7b607e7505188127b74678f9f13a2222bc50203010001a000300d06092a864886f70d01010b0500038201010060f76944264ee26ca31814e560048427a1596c976906c62d1147bcd01b3d8adafaae7bd01e682732a3da6e56c3f0da4908dad2e6ec1a399cc41dbfe4b240ed3c318301fb9f4a1510f396a5cab91cecb69893afb523bd5641994273994ec181f55e5edec3fbaad4274152c499c294464abaf0c1563d04d8ddc5efdd123b3d992132c82979189b232589cd2bca77cdfc59bade2129542d95100b274d529d97d27ca53105c3847def151ecfac8d12e398192ff33a827d5b5bb042b2276b3d8e31915e5a2788a929a45f1dd29d4cdf472c899ffe9692aa8dab958644e00705bd1b187df5c3394bb180ad742c03058b5e8e38a1257877787b01fd120c93edd8de6668";

// _data/0csr1/key2.csr3.hex (generated by OpenSSL SHA1)
var key2csr3hex = "308202773082015f0201003032310b3009060355040613025553310d300b060355040a0c04546573743114301206035504030c0b6578616d706c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100e7fd901cc041be2aeb8ae7218a9479d3645ade837f8ddb97948162d1e5a941e9b64b422b2b0822057f7e84d9e386a321397a7893fe88b82387e8f211a494a417537fb6eef2a734d5c274fc2d0a1fe5d69142d78714f537c3731e95db84e6718f8c997c8dc577ea3b6fb7b9e79198c9bd93e5b902cd02de9acc8bc8df5050a8d203d71dd12034f155ae80f79dae9ddb68ebaf6c52e39c8d4085c70602937bb99bcf51a5aca8c8010adebaba5db485faca62ad62c7783174779f21306bdbc08f183e7a7b74d44f534f1683d414244f252447ccc805ce61ad9e29193d9aa07b8e41180c78aa34fce3b26dc24f46a69fc7b607e7505188127b74678f9f13a2222bc50203010001a000300d06092a864886f70d0101050500038201010015ca0b78733822afab6cd69f214c60b62c63639abb92397ddd974cfa1c6e1c186aefa7d5fbd4b2c98bcfacc7572f4856f2635c5da1126062f0ea8ce6b41f959dd5232d441d453a11d7129ef449209ced804920512a0e8b0f0980abbebec76a319636ce1fa9bb46e7abb21f47c2cd8350c3f4d36a857bd16444573b74e34618e8962e01e8316ab7508ca90364a160eeb162b4c90ca6654243e6dc0ed3ed1b8a0dcc29263777b9ffe1ec1829bb54ecb12f0e1998762cdc4f4087add6b6d31d8f96ba5001e4d37c7ee09805cf5b7fecc061402aba8692ef5d573ded54d080016a4f3e80d9c9ca7b6fa121a555a23326dfee6119a6d7562db1cac9d083ff0e2a178c";

// _data/0csr1/key2.csr (generated by OpenSSL SHA256 PEM)
var key2csrpem = "" +
"-----BEGIN CERTIFICATE REQUEST-----\r\n" +
"MIICdzCCAV8CAQAwMjELMAkGA1UEBhMCVVMxDTALBgNVBAoMBFRlc3QxFDASBgNV\r\n" +
"BAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\r\n" +
"5/2QHMBBvirriuchipR502Ra3oN/jduXlIFi0eWpQem2S0IrKwgiBX9+hNnjhqMh\r\n" +
"OXp4k/6IuCOH6PIRpJSkF1N/tu7ypzTVwnT8LQof5daRQteHFPU3w3MelduE5nGP\r\n" +
"jJl8jcV36jtvt7nnkZjJvZPluQLNAt6azIvI31BQqNID1x3RIDTxVa6A952undto\r\n" +
"669sUuOcjUCFxwYCk3u5m89RpayoyAEK3rq6XbSF+spirWLHeDF0d58hMGvbwI8Y\r\n" +
"Pnp7dNRPU08Wg9QUJE8lJEfMyAXOYa2eKRk9mqB7jkEYDHiqNPzjsm3CT0amn8e2\r\n" +
"B+dQUYgSe3Rnj58ToiIrxQIDAQABoAAwDQYJKoZIhvcNAQELBQADggEBAGD3aUQm\r\n" +
"TuJsoxgU5WAEhCehWWyXaQbGLRFHvNAbPYra+q570B5oJzKj2m5Ww/DaSQja0ubs\r\n" +
"GjmcxB2/5LJA7TwxgwH7n0oVEPOWpcq5HOy2mJOvtSO9VkGZQnOZTsGB9V5e3sP7\r\n" +
"qtQnQVLEmcKURkq68MFWPQTY3cXv3RI7PZkhMsgpeRibIyWJzSvKd838WbreISlU\r\n" +
"LZUQCydNUp2X0nylMQXDhH3vFR7PrI0S45gZL/M6gn1bW7BCsidrPY4xkV5aJ4ip\r\n" +
"KaRfHdKdTN9HLImf/paSqo2rlYZE4AcFvRsYffXDOUuxgK10LAMFi16OOKEleHd4\r\n" +
"ewH9EgyT7djeZmg=\r\n" +
"-----END CERTIFICATE REQUEST-----\r\n";

// _data/0csrext/z9.pem
var csrextpem = "" +
"-----BEGIN CERTIFICATE REQUEST-----\r\n" +
"MIICozCCAYsCAQAwMjELMAkGA1UEBhMCVVMxDTALBgNVBAoMBFRlc3QxFDASBgNV\r\n" +
"BAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\r\n" +
"5/2QHMBBvirriuchipR502Ra3oN/jduXlIFi0eWpQem2S0IrKwgiBX9+hNnjhqMh\r\n" +
"OXp4k/6IuCOH6PIRpJSkF1N/tu7ypzTVwnT8LQof5daRQteHFPU3w3MelduE5nGP\r\n" +
"jJl8jcV36jtvt7nnkZjJvZPluQLNAt6azIvI31BQqNID1x3RIDTxVa6A952undto\r\n" +
"669sUuOcjUCFxwYCk3u5m89RpayoyAEK3rq6XbSF+spirWLHeDF0d58hMGvbwI8Y\r\n" +
"Pnp7dNRPU08Wg9QUJE8lJEfMyAXOYa2eKRk9mqB7jkEYDHiqNPzjsm3CT0amn8e2\r\n" +
"B+dQUYgSe3Rnj58ToiIrxQIDAQABoCwwKgYJKoZIhvcNAQkOMR0wGzALBgNVHQ8E\r\n" +
"BAMCBsAwDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQsFAAOCAQEAhECKMWDIUIYv\r\n" +
"JScXOQPMWF5w0bg/sjLFRX7es6pi9mSBy0jqDtVN8dxvawXjv5/ijY7DH7QGl73U\r\n" +
"L86u3QM9tjAjmDGRCjEJCQi8kFsn0FpjEGFCvEPekAB/8/FsIPsNHd/RZ+Y/mA5h\r\n" +
"tBbPcacISJE2Hvcq12vvGabLZGLTCBth/MsEc0QffnpCWkLTYwG6+iQVixNuHiOX\r\n" +
"GtLPuvhrNbaKiIt/GzVtI+YApb17BFbUJ/v28w9y7mRZj1Dle8XzHVwGw0HR/aZs\r\n" +
"2aU6zdmJpP9CX7vZLKBrslhVkCdXuALijEktNwInCQEyVNbO/y1yRNuI6WT9KmBK\r\n" +
"aeFpEQeMdw==\r\n" +
"-----END CERTIFICATE REQUEST-----\r\n";

// _data/0csrext/certbot1.csr.pem
var csrcertbot1 = (function() {/*
-----BEGIN CERTIFICATE REQUEST-----
MIICeDCCAWACAQIwADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMf6
wBbRavWLUCZfLNF+C4uNO/T6N2YCxWgM/XI04hPLqQodfTudcIwsbWGGkRpJSwGG
pDXQs3A1fH5xrfev7PlWaDYCkhC4jrrZ/1L8HGR/nUxrS3jFTbzZTGA84TbkW8FH
fyugWWqnjrnoxOJW0XdiWe1Drsr5vaqVS0N4qEISH/ciLnaVeV//tLJc/V5g3sFu
4AQZQykvkltGD7w8vBhM4a/KQGeV3hG+ctCAwV5+RhQxForDgUv3ZPt76yVt142x
TJGsq8fsdEqBjg7xVQn+458Z3yMMQVMLCf/aEHFLYurc6PD2kEzJf+mRYXY3sNwy
4l38Qf8velG6Ij+8eVkCAwEAAaAzMDEGCSqGSIb3DQEJDjEkMCIwIAYDVR0RBBkw
F4IVbm9kZWpzLnJ6LWJzZC5teS5jb3JwMA0GCSqGSIb3DQEBCwUAA4IBAQB0isgR
I57C2GCszZdLdouAjpIZXa8W1C3FjOHcd6RQ77Fd+h22fn63gEMBUQk3AFzq4t2b
8JeOH1xjZ4gjTEXH4whOh95gR+LDvVmK3khIHBLMVCyJgUEUNTZJoaMu7adhpbJX
taiHpny63sQvh3QtEh7arMx8EaDh8MKYBQ5iTylvN0SS/yQcUvaS4kFs5CJTE/YG
FepaWdBWPlE4C5oJ956lnuZSRHlugKHUzWD/V/tSYLDJmQVJ7sPNJM1JaTd79cDq
cbtqMCqhg0GKH4OmbrS+Zu99iox+I7Mbsu9+F4rZjinez1looQ5hfJ+6FAtxE1HI
2/x4YDGRZtDqwcFe
-----END CERTIFICATE REQUEST-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

var certbot1PUBPEM = (function() {/*
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx/rAFtFq9YtQJl8s0X4L
i4079Po3ZgLFaAz9cjTiE8upCh19O51wjCxtYYaRGklLAYakNdCzcDV8fnGt96/s
+VZoNgKSELiOutn/UvwcZH+dTGtLeMVNvNlMYDzhNuRbwUd/K6BZaqeOuejE4lbR
d2JZ7UOuyvm9qpVLQ3ioQhIf9yIudpV5X/+0slz9XmDewW7gBBlDKS+SW0YPvDy8
GEzhr8pAZ5XeEb5y0IDBXn5GFDEWisOBS/dk+3vrJW3XjbFMkayrx+x0SoGODvFV
Cf7jnxnfIwxBUwsJ/9oQcUti6tzo8PaQTMl/6ZFhdjew3DLiXfxB/y96UboiP7x5
WQIDAQAB
-----END PUBLIC KEY-----
*/}).toString().match(/\/\*([^]*)\*\//)[1];

// ======= TEST ===============================================================

test("(1) CertificationRequestInfo", function() {
var hExpect = "307e0201003019310b3009060355040613025553310a300806035504030c0162305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a000";
var param = {
subject: {str: '/C=US/CN=b'},
sbjpubkey: z1PubP8PEM
};
var csri = new KJUR.asn1.csr.CertificationRequestInfo(param);
equal(
csri.getEncodedHex(), 
hExpect,
"z1 csr no ext hex");
equal(ASN1HEX.dump(csri.getEncodedHex()), ASN1HEX.dump(hExpect), "dump");
});

test("(2) CertificationRequestInfo with extreq", function() {
var hExpect = "3081ad0201003019310b3009060355040613025553310a300806035504030c0162305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a02f302d06092a864886f70d01090e3120301e300b0603551d0f0404030206c0300f0603551d130101ff040530030101ff";
var param = {
subject: {str: '/C=US/CN=b'},
sbjpubkey: z1PubP8PEM,
extreq: [
 {extname:"keyUsage", names:["digitalSignature","nonRepudiation"]},
 {extname:"basicConstraints", cA:true, critical:true}
]
};
var csri = new KJUR.asn1.csr.CertificationRequestInfo(param);
equal(
csri.getEncodedHex(),
hExpect,
"z1 csr with ext hex");
equal(ASN1HEX.dump(csri.getEncodedHex()), ASN1HEX.dump(hExpect), "dump");
});

test("(2-1) CertificationRequestInfo with attrs[unstructuredName,challengePassword,extensionRequest]", function() {
var param = {
subject: {str: '/C=US/CN=b'},
sbjpubkey: z1PubP8PEM,
attrs: [
  {attr:"challengePassword", password: "PassWord"},
  {attr:"unstructuredName", names: [{ia5str:"aaa"},{utf8str:"bbb"}]},
  {attr:"extensionRequest", ext: [
    {extname: "basicConstraints", cA: true}
  ]}
]
};
var hExpect = "3081d10201003019310b3009060355040613025553310a300806035504030c0162305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a0533151301706092a864886f70d010902310a0c036262621603616161301706092a864886f70d010907310a0c0850617373576f7264301d06092a864886f70d01090e3110300e300c0603551d13040530030101ff";
var csri = new KJUR.asn1.csr.CertificationRequestInfo(param);
equal(csri.tohex(), hExpect, "hex");
equal(ASN1HEX.dump(csri.tohex()), ASN1HEX.dump(hExpect), "dump");
});

test("(3) CertificationRequestInfo.appendExtensionByName", function() {
var hExpect = "3081ad0201003019310b3009060355040613025553310a300806035504030c0162305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a02f302d06092a864886f70d01090e3120301e300b0603551d0f0404030206c0300f0603551d130101ff040530030101ff";
var param = {
subject: {'str': '/C=US/CN=b'},
sbjpubkey: z1PubP8PEM,
extreq: [
 {extname:"keyUsage", names:["digitalSignature","nonRepudiation"]},
 {extname:"basicConstraints", cA:true, critical:true}
]
};
var csri = new KJUR.asn1.csr.CertificationRequestInfo(param);
equal(csri.getEncodedHex(), 
hExpect,
"keyUsage, basicConstraints");
equal(ASN1HEX.dump(csri.getEncodedHex()), ASN1HEX.dump(hExpect), "dump");
});

test("(4) CertificationRequestInfo key2pub", function() {
var param = {
subject: {'str': '/C=US/O=Test/CN=example.com'},
sbjpubkey: key2pub
};
var csri = new KJUR.asn1.csr.CertificationRequestInfo(param);
equal(csri.getEncodedHex(), 
"3082015f0201003032310b3009060355040613025553310d300b060355040a0c04546573743114301206035504030c0b6578616d706c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100e7fd901cc041be2aeb8ae7218a9479d3645ade837f8ddb97948162d1e5a941e9b64b422b2b0822057f7e84d9e386a321397a7893fe88b82387e8f211a494a417537fb6eef2a734d5c274fc2d0a1fe5d69142d78714f537c3731e95db84e6718f8c997c8dc577ea3b6fb7b9e79198c9bd93e5b902cd02de9acc8bc8df5050a8d203d71dd12034f155ae80f79dae9ddb68ebaf6c52e39c8d4085c70602937bb99bcf51a5aca8c8010adebaba5db485faca62ad62c7783174779f21306bdbc08f183e7a7b74d44f534f1683d414244f252447ccc805ce61ad9e29193d9aa07b8e41180c78aa34fce3b26dc24f46a69fc7b607e7505188127b74678f9f13a2222bc50203010001a000",
"aaa");
});

test("(5) CertificationRequest SHA1withRSA", function() {
var hExpect = "3081d2307e0201003019310b3009060355040613025553310a300806035504030c0162305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a000300d06092a864886f70d010105050003410078a1bcf448392f6f1d3da500f18b85b763c71415c3a2a6460fe555b01793d2665ea5d5b76bd4c0b4b3affd6e4b50c4941fffab930240ad411fa378f3c719934d";
var prvKey = KEYUTIL.getKey(z1PrvP5EPEM, "hoge");
var params = {
subject: {'str': '/C=US/CN=b'},
sbjpubkey: z1PubP8PEM,
sigalg: "SHA1withRSA",
sbjprvkey: prvKey
};
var csr = new KJUR.asn1.csr.CertificationRequest(params);
equal(
csr.getEncodedHex(), 
hExpect,
 "aaa");
});

test("(6) CertificationRequest SHA256withRSA", function() {
var hExpect = "3081d2307e0201003019310b3009060355040613025553310a300806035504030c0162305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a000300d06092a864886f70d01010b0500034100966e2cc2e53e277beaa639b444e0e463abefc3f1d4841e93a8088e07862d4dd58b6c83492b3dc8f3076f031060b931272d1248e5c08ccd2c34cb63c90a06211e";
var prvKey = KEYUTIL.getKey(z1PrvP5EPEM, "hoge");
var params = {
subject: {'str': '/C=US/CN=b'},
sbjpubkey: z1PubP8PEM,
sigalg: "SHA256withRSA",
sbjprvkey: prvKey
};
var csr = new KJUR.asn1.csr.CertificationRequest(params);
equal(csr.getEncodedHex(), 
hExpect,
 "aaa");
equal(ASN1HEX.dump(csr.getEncodedHex()), ASN1HEX.dump(hExpect), "dump");
});

test("(7) CertificationRequest SHA256withRSA key2pub/prv", function() {
var prvKey = KEYUTIL.getKey(key2prv);
var params = {
subject: {'str': '/C=US/O=Test/CN=example.com'},
sbjpubkey: key2pub,
sigalg: "SHA256withRSA",
sbjprvkey: prvKey
};
var csr = new KJUR.asn1.csr.CertificationRequest(params);
equal(csr.getEncodedHex(), key2csrhex, "csr compare to the one generated by openssl/sha256/key2");
equal(ASN1HEX.dump(csr.getEncodedHex()), ASN1HEX.dump(key2csrhex), "dump");
});

test("(8) CertificationRequest SHA1withRSA key2pub/prv", function() {
var prvKey = KEYUTIL.getKey(key2prv);
var params = {
subject: {'str': '/C=US/O=Test/CN=example.com'},
sbjpubkey: key2pub,
sigalg: "SHA1withRSA",
sbjprvkey: prvKey
};
var csr = new KJUR.asn1.csr.CertificationRequest(params);
equal(csr.getEncodedHex(), key2csr3hex, "csr compare HEX to the one generated by openssl/sha1/key2");
equal(ASN1HEX.dump(csr.getEncodedHex()), ASN1HEX.dump(key2csr3hex), "dump");
});

test("(9) CertificationRequest.getPEMString SHA256withRSA key2pub/prv", function() {
var prvKey = KEYUTIL.getKey(key2prv);
var params = {
subject: {'str': '/C=US/O=Test/CN=example.com'},
sbjpubkey: key2pub,
sigalg: "SHA256withRSA",
sbjprvkey: prvKey
};
var csr = new KJUR.asn1.csr.CertificationRequest(params);
equal(csr.getPEM(), key2csrpem, "csr compare PEM to the one generated by openssl/sha1/key2");
});

test("(10) CertificationRequest by sighex (not sign)", function() {
var hExpected = "308201793082015f0201003032310b3009060355040613025553310d300b060355040a0c04546573743114301206035504030c0b6578616d706c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100e7fd901cc041be2aeb8ae7218a9479d3645ade837f8ddb97948162d1e5a941e9b64b422b2b0822057f7e84d9e386a321397a7893fe88b82387e8f211a494a417537fb6eef2a734d5c274fc2d0a1fe5d69142d78714f537c3731e95db84e6718f8c997c8dc577ea3b6fb7b9e79198c9bd93e5b902cd02de9acc8bc8df5050a8d203d71dd12034f155ae80f79dae9ddb68ebaf6c52e39c8d4085c70602937bb99bcf51a5aca8c8010adebaba5db485faca62ad62c7783174779f21306bdbc08f183e7a7b74d44f534f1683d414244f252447ccc805ce61ad9e29193d9aa07b8e41180c78aa34fce3b26dc24f46a69fc7b607e7505188127b74678f9f13a2222bc50203010001a000300d06092a864886f70d01010b05000305001a2b3c4d";
var prvKey = KEYUTIL.getKey(key2prv);
var params = {
subject: {'str': '/C=US/O=Test/CN=example.com'},
sbjpubkey: key2pub,
sigalg: "SHA256withRSA",
sighex: "1a2b3c4d"
};
var csr = new KJUR.asn1.csr.CertificationRequest(params);
equal(csr.getEncodedHex(), hExpected, "by sighex");
equal(ASN1HEX.dump(csr.getEncodedHex()), ASN1HEX.dump(hExpected), "IGNORE check dump");
});

test("(11) CSRUtil.newCSRPEM by keyPEM SHA256withRSA key2pub/prv", function() {
var pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
  subject: {str: '/C=US/O=Test/CN=example.com'},
  sbjpubkey: key2pub,
  sigalg: "SHA256withRSA",
  sbjprvkey: key2prv
});
equal(pem, key2csrpem, "CSR PEM compare to the one generated by openssl/sha1/key2");
});

test("(12) CSRUtil.newCSRPEM by keyObj SHA256withRSA key2pub/prv", function() {
var prvKey = KEYUTIL.getKey(key2prv);
var pubKey = KEYUTIL.getKey(key2pub);
var pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
  subject: {str: '/C=US/O=Test/CN=example.com'},
  sbjpubkey: pubKey,
  sigalg: "SHA256withRSA",
  sbjprvkey: prvKey
});
equal(pem, key2csrpem, "CSR PEM compare to the one generated by openssl/sha1/key2");
});

test("(13) CSRUtil.newCSRPEM with extensionRequest", function() {
var prvKey = KEYUTIL.getKey(key2prv);
var pubKey = KEYUTIL.getKey(key2pub);
var pem = KJUR.asn1.csr.CSRUtil.newCSRPEM({
  subject: {str: '/C=US/O=Test/CN=example.com'},
  sbjpubkey: pubKey,
  sigalg: "SHA256withRSA",
  sbjprvkey: prvKey,
  extreq: [
    {extname:'keyUsage', names:['digitalSignature','nonRepudiation']},
    {extname:'basicConstraints',critical:true}
  ]
});
equal(pem, csrextpem, "CSR PEM keyusage, basicconstraints");
});

test("CSRUtil.getParam(key2.csr) without tbs", function() {
var p = KJUR.asn1.csr.CSRUtil.getParam(key2csrpem);
var pExpect = {
  subject: {
    array: [
      [{type: "C", value: "US", ds: "prn"}],
      [{type: "O", value: "Test", ds: "utf8"}],
      [{type: "CN", value: "example.com", ds: "utf8"}]
    ],
    str: "/C=US/O=Test/CN=example.com"
  },
  sbjpubkey: key2pub.substr(1).replace(/\n/g, "\r\n"),
  sigalg: "SHA256withRSA",
  sighex: "60f76944264ee26ca31814e560048427a1596c976906c62d1147bcd01b3d8adafaae7bd01e682732a3da6e56c3f0da4908dad2e6ec1a399cc41dbfe4b240ed3c318301fb9f4a1510f396a5cab91cecb69893afb523bd5641994273994ec181f55e5edec3fbaad4274152c499c294464abaf0c1563d04d8ddc5efdd123b3d992132c82979189b232589cd2bca77cdfc59bade2129542d95100b274d529d97d27ca53105c3847def151ecfac8d12e398192ff33a827d5b5bb042b2276b3d8e31915e5a2788a929a45f1dd29d4cdf472c899ffe9692aa8dab958644e00705bd1b187df5c3394bb180ad742c03058b5e8e38a1257877787b01fd120c93edd8de6668"
};
deepEqual(p, pExpect, "key2.csr all members without tbs");
});

test("CSRUtil.getParam(certbot1.csr.pem) (with san, no sbjname)", function() {
var p = KJUR.asn1.csr.CSRUtil.getParam(csrcertbot1);
var pExpect = {
  subject: {},
  sbjpubkey: certbot1PUBPEM.substr(1).replace(/\n/g, "\r\n"),
  extreq: [
    { extname: "subjectAltName",
      array: [{dns: "nodejs.rz-bsd.my.corp"}]}
  ],
  sigalg: "SHA256withRSA",
  sighex: "748ac811239ec2d860accd974b768b808e92195daf16d42dc58ce1dc77a450efb15dfa1db67e7eb7804301510937005ceae2dd9bf0978e1f5c636788234c45c7e3084e87de6047e2c3bd598ade48481c12cc542c89814114353649a1a32eeda761a5b257b5a887a67cbadec42f87742d121edaaccc7c11a0e1f0c298050e624f296f374492ff241c52f692e2416ce4225313f60615ea5a59d0563e51380b9a09f79ea59ee65244796e80a1d4cd60ff57fb5260b0c9990549eec3cd24cd4969377bf5c0ea71bb6a302aa183418a1f83a66eb4be66ef7d8a8c7e23b31bb2ef7e178ad98e29decf5968a10e617c9fba140b711351c8dbfc7860319166d0eac1c15e"
};
deepEqual(p, pExpect, "certbot1.csr all members without tbs");
});

test("CSRUtil.getParam(key2csr, flagTBS=true)", function() {
var p = KJUR.asn1.csr.CSRUtil.getParam(key2csrpem, true);
var pExpect = {
  subject: {
    array: [
      [{type: "C", value: "US", ds: "prn"}],
      [{type: "O", value: "Test", ds: "utf8"}],
      [{type: "CN", value: "example.com", ds: "utf8"}]
    ],
    str: "/C=US/O=Test/CN=example.com"
  },
  sbjpubkey: key2pub.substr(1).replace(/\n/g, "\r\n"),
  sigalg: "SHA256withRSA",
  sighex: "60f76944264ee26ca31814e560048427a1596c976906c62d1147bcd01b3d8adafaae7bd01e682732a3da6e56c3f0da4908dad2e6ec1a399cc41dbfe4b240ed3c318301fb9f4a1510f396a5cab91cecb69893afb523bd5641994273994ec181f55e5edec3fbaad4274152c499c294464abaf0c1563d04d8ddc5efdd123b3d992132c82979189b232589cd2bca77cdfc59bade2129542d95100b274d529d97d27ca53105c3847def151ecfac8d12e398192ff33a827d5b5bb042b2276b3d8e31915e5a2788a929a45f1dd29d4cdf472c899ffe9692aa8dab958644e00705bd1b187df5c3394bb180ad742c03058b5e8e38a1257877787b01fd120c93edd8de6668",
  tbs: "3082015f0201003032310b3009060355040613025553310d300b060355040a0c04546573743114301206035504030c0b6578616d706c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100e7fd901cc041be2aeb8ae7218a9479d3645ade837f8ddb97948162d1e5a941e9b64b422b2b0822057f7e84d9e386a321397a7893fe88b82387e8f211a494a417537fb6eef2a734d5c274fc2d0a1fe5d69142d78714f537c3731e95db84e6718f8c997c8dc577ea3b6fb7b9e79198c9bd93e5b902cd02de9acc8bc8df5050a8d203d71dd12034f155ae80f79dae9ddb68ebaf6c52e39c8d4085c70602937bb99bcf51a5aca8c8010adebaba5db485faca62ad62c7783174779f21306bdbc08f183e7a7b74d44f534f1683d414244f252447ccc805ce61ad9e29193d9aa07b8e41180c78aa34fce3b26dc24f46a69fc7b607e7505188127b74678f9f13a2222bc50203010001a000"
};
deepEqual(p, pExpect, "key2.csr all members including tbs");
});

test("CSRUtil.verifySignature(key2csrpem)", function() {
equal(KJUR.asn1.csr.CSRUtil.verifySignature(key2csrpem), true, "valid key2csr pem");

var pCSR = KJUR.asn1.csr.CSRUtil.getParam(key2csrpem, true);
equal(KJUR.asn1.csr.CSRUtil.verifySignature(pCSR), true, "valid key2csr obj");

var pCSR2 = KJUR.asn1.csr.CSRUtil.getParam(key2csrpem, true);
pCSR2.sighex = pCSR2.sighex.substr(2) + "ab"; // forge signature
equal(KJUR.asn1.csr.CSRUtil.verifySignature(pCSR2), false, "invalid forged key2csr obj");
});

});

-->
</script>
  
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<a href="index.html">TEST INDEX</a> |
<a href="qunit-do-asn1x509.html">asn1x509</a> |
<a href="qunit-do-asn1x509-tbscert.html">asn1x509-tbscert</a> |
<a href="qunit-do-asn1csr.html">asn1csr</a> |
</body>
</html>

